package ahut2020.exp12;

import java.util.Arrays;

public class TestShuffle {
    public static void main(String[] args) {
        int n = 10;
        int[] a = new int[n];
        int[][] b = new int[n][n];

        for (int k = 0; k < 10000000; k++) {
            for (int i = 0; i < n; i++) {
                a[i] = i;
            }
            //shuffle2(a);
            shuffle(a);
            // System.out.println(Arrays.toString(a));
            for (int i = 0; i < n; i++) {
                b[a[i]][i]++;
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.println(Arrays.toString(b[i]));
        }

    }

    static void shuffle(int[] a) {
        for (int i = 0; i < a.length; i++) {
            int j = (int) (Math.random() * a.length);//j~U[0,n）
            int t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
    }

    static void shuffle2(int[] a) {
        for (int i = 0; i < a.length; i++) {
            int j = (int) (Math.random() * (a.length - i)) + i;//j~U[i,n）
            int t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
    }

}
